#include <QCoreApplication>
#include <QDBusConnection>
#include <QDBusError>
#include <QDebug>

#include "connectivitymanager.h"

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
    app.setOrganizationName("kylin connectivity");
    app.setApplicationName("kylin connectivity manager");

    QDBusConnection systemBus = QDBusConnection::systemBus();
    if (!systemBus.isConnected()) {
        qCritical() << "d-bus connection fail !";
        return -1;
    }

    if (!systemBus.registerService("com.kylin.connectivity.manager")) {
        qCritical() << "d-bus register service fail ! d-bus error : " << systemBus.lastError();
        return -1;
    }

    if (!systemBus.registerObject("/", new ConnectivityManager,
                                  QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals)) {
        qCritical() << "d-bus register crash object fail ! d-bus error : " << systemBus.lastError();
        return -1;
    }

    return app.exec();
}